﻿using IdentityServer4.SqlSugarCore.Entities;
using Microsoft.Extensions.Options;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace IdentityServer4.SqlSugarCore.DbContexts
{
    public class DbContext
    {
        public DbContext(SugarStoreOptions option)
        {
            var config = new ConnectionConfig()
            {
                ConnectionString = option.DbConnectionStrings,
                DbType = option.DbType,
                InitKeyType = InitKeyType.Attribute,
                IsAutoCloseConnection = true
            };

            Db = new SqlSugarClient(config);
            //Db.DbMaintenance.CreateDatabase();
        }

        public ISqlSugarClient Db;//用来处理事务多表查询和复杂的操作
    }
}
